package com.campus.mapper;

import com.campus.pojo.dto.StudentDormDTO;
import com.campus.pojo.dto.StudentDormPageQueryDTO;
import com.campus.pojo.vo.StudentDormVO;
import com.github.pagehelper.Page;
import org.apache.ibatis.annotations.*;

@Mapper
public interface StudentDormSharedMapper {
    /**
     * 学生宿舍信息分页查询
     * @param studentDormPageQueryDTO
     * @return
     */
    Page<StudentDormVO> list(StudentDormPageQueryDTO studentDormPageQueryDTO);

    @Delete("delete from student_dorm_share where student_id = #{id}")
    void deleteByStudentId(Long id);

    @Insert("insert into student_dorm_share(dorm_id, student_id, bed_number) value (#{dormId}, #{id}, #{bedNumber})")
    void addDormInfo(StudentDormDTO dormDTO);

    @Select("select count(dorm_id) from student_dorm_share where dorm_id =#{dormId}")
    int getDormPeopleNumber(Integer dormId);
}
